package org.awenlice.playerdailyshop;

import net.minecraft.server.level.ServerLevel;
import net.minecraftforge.event.server.ServerStoppingEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.eventbus.api.IEventBus;
import org.awenlice.playerdailyshop.config.ConfigHelper;
import org.awenlice.playerdailyshop.data.CustomServerDataManager;
import org.awenlice.playerdailyshop.network.PacketHandler;

@Mod(PlayerDailyShop.MODID)
public class PlayerDailyShop {
    public static final String MODID = "playerdailyshop";

    public PlayerDailyShop() {
        // 获取 Mod 事件总线
        IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
        // 注册数据包
        PacketHandler.register();
        // 注册初始化事件
        modEventBus.addListener(this::setup);


    }

    private void setup(final FMLCommonSetupEvent event) {
        // 检测并生成配置文件
        ConfigHelper.checkAndGenerateConfig();

        // 加载配置文件
        ConfigHelper.loadConfig();
    }

    @SubscribeEvent
    public void onServerStopping(ServerStoppingEvent event) {

    }
}